import 'package:dio/dio.dart';
import 'package:ost_flutter_module/help/global/global_cache.dart';

import 'url_constants.dart';

class HeaderInterceptor extends Interceptor {
  @override
  Future onRequest(RequestOptions options) {
    String token = "";
    String cachedToken = GlobalCache.getInstance().getToken();
    // if (options.uri.path.contains(URL_LOGIN)) {
    //   token = "Basic Y2xpZW50XzI6c2VjcmV0";
    // } else if (cachedToken != null && cachedToken.isNotEmpty) {
    //   token = "Bearer $cachedToken";
    // }

    token = cachedToken;
    options.headers["Authorization"] = token;
    return super.onRequest(options);
  }
}
